using System;
using System.Diagnostics;

namespace WindsorContainerTry.Newsletter
{
    public class NewsLetterService : INewsLetterService
    {
        private readonly IMailSender sender;
        private readonly ITempleteEngine engine;

        public NewsLetterService(IMailSender sender, ITempleteEngine engine)
        {
            this.sender = sender;
            this.engine = engine;
        }

        #region INewsLetterService Members

        public bool Dispatch(string from, string to, string messageType)
        {
            string message = engine.Process(messageType);

            // To see which template manager is used. Result willl be shown in test window.
            Debug.Write(message);

            return sender.Send(from, to, message);
        }

        public string Subject { get; set; }

        #endregion
    }
}